// NOWHINE NC009 <- Shared file with system team so uses non-CamX file naming
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  ica10setting.h
/// @brief ICA1_0 module setting calculation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef ICA10SETTING_H
#define ICA10SETTING_H

#include "iqcommondefs.h"
#include "iqsettingutil.h"

/// @brief ICA10 Module Unpacked Data Structure
// NOWHINE NC004c: Share code with system team
struct ICA10UnpackedField
{
    VOID*            pIcaParameter;          ///< Pointer pointing to IPE IQ settings
    VOID*            pRegData;               ///< Pointer to REG data
    VOID*            pCurrICAInData;         ///< ICA input current frame Data
    VOID*            pPrevICAInData;         ///< ICA reference current frame Data
    VOID*            pCurrWarpAssistData;    ///< Current Warp assist data
    VOID*            pPrevWarpAssistData;    ///< Current Warp assist data
    // Warp geometry data required by ANR/TF
    VOID*            pWarpGeometryData;      ///< Warp Geometry data
};

/// @brief: This enumerator maps Look Up Tables indices with DMI LUT_SEL in ICA module SWI.
enum IPEICALUTIndex
{
    ICAIndexPerspective = 0,    ///< Perspective Index
    ICAIndexGrid0       = 1,    ///< Grid0 Index
    ICAIndexGrid1       = 2,    ///< Grid1 Index
    ICAIndexmax         = 3     ///< ICA Index max
};

/// @brief: This structure has information of number of entries of each LUT in words.
static const UINT32 IPEICALUTNumEntries[ICAIndexmax] =
{
    72,     ///< Perspective LUT
    832,    ///< Grid LUT 0, these are 64 bit LUTs. 415 used.
    832,    ///< Grid LUT 1, these are 64 bit LUTs. 414 used.
};

/// @brief: This array has information of number of entried of each LUT in bytes.
static const UINT IPEICALUTSize[ICAIndexmax] =
{
    static_cast<UINT>(IPEICALUTNumEntries[0] * sizeof(UINT32)),
    static_cast<UINT>(IPEICALUTNumEntries[1] * sizeof(UINT32)),
    static_cast<UINT>(IPEICALUTNumEntries[2] * sizeof(UINT32)),
};

/// @brief: Total size of LUT Buffer
static const UINT32 IPEICALUTBufferSize =
    IPEICALUTSize[ICAIndexPerspective] +
    IPEICALUTSize[ICAIndexGrid0] +
    IPEICALUTSize[ICAIndexGrid1];


// Total Entries 904 (Sum of all entries from all LUT curves)
static const UINT IPEMaxICALUTNumEntries = 1736;

static const UINT32 ICAREGSIZE      = 8960;
static const UINT32 NCLIBCONTEXTICA = 6968;
static const UINT32 ICAChromatix   = 20120;

static const UINT ICAGridRegSize     = 829;
static const UINT ICAPerspectiveSize = 72;
static const UINT ICAGridLUTSize     = 416;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Class that implements ICA10 module setting calculation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// NOWHINE NC004c: Share code with system team
class ICA10Setting
{
public:
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// CalculateHWSetting
    ///
    /// @brief  Calculate the unpacked register value
    ///
    /// @param  pInput          ICA input data
    /// @param  pData           Chromatix region data pointer
    /// @param  pReserveData    Chromatix reserve data pointer
    /// @param  pOutput         Output data pointer
    ///
    /// @return TRUE for success
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    static BOOL CalculateHWSetting(
        const ICA10InputData*                   pInput,
        ica_1_0_0::ica10_rgn_dataType*          pData,
        ica_1_0_0::chromatix_ica10_reserveType* pReserveData,
        VOID*                                   pOutput);

private:
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// ValidateContextParams
    ///
    /// @brief  Calculate the unpacked register value
    ///
    /// @param  pInput  Pointer to input parameters
    ///
    /// @return TRUE for success
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    static BOOL ValidateContextParams(
        const ICA10InputData*  pInput);

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// DumpContextParams
    ///
    /// @brief  Calculate the unpacked register value
    ///
    /// @param  pInput    Pointer to input parameters
    /// @param  pData     Chromatix region data pointer
    ///
    /// @return TRUE for success
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    static BOOL DumpContextParams(
        const ICA10InputData*          pInput,
        ica_1_0_0::ica10_rgn_dataType* pData);

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// MapChromatixMod2ICAv10Chromatix
    ///
    /// @brief  Calculate the unpacked register value
    ///
    /// @param  pInput           ICA input data
    /// @param  pReserveData     Chromatix reserve data pointer
    /// @param  pData            Chromatix region data pointer
    /// @param  pIcaChromatix    ICA Chromatix structure
    ///
    /// @return TRUE for success
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    static BOOL  MapChromatixMod2ICAv10Chromatix(
        const ICA10InputData*                   pInput,
        ica_1_0_0::chromatix_ica10_reserveType* pReserveData,
        ica_1_0_0::ica10_rgn_dataType*          pData,
        VOID*                                   pIcaChromatix);

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /// CheckMctfTransformCondition
    ///
    /// @brief  Check MCTF Transform Condition.
    ///
    /// @param  pMCTF     Pointer to NcLibCalcMctfIn Data
    /// @param  pWarpOut  Pointer to NcLibWarp Data
    /// @param  mctfEis   Flag indicating if mctf and eis are both enabled
    ///
    /// @return TRUE for doing MCTF Transform
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    static BOOL CheckMctfTransformCondition(
        VOID*  pMCTF,
        VOID*  pWarpOut,
        BOOL   mctfEis);
};
#endif // ICA10SETTING_H
